/*
 * @Author: silas  
 * @Date: 2020-11-24 17:47:34 
 * @Last Modified by: silas
 * @Last Modified time: 2020-11-24 17:49:12
 */
<template>
  <div class="virtualLogin_container t" v-loading="showAllLoading"></div>
</template>

<script>
import { getRequestParams } from "@/common/js/fastInquiryFn2";
import { setCookie, delCookie } from "@/common/js/cookie";
import { setSessionStorage } from "@/common/js/storage";
import { $loginAPI } from "@/api";
export default {
  data() {
    return {
      showAllLoading: true,
      param: null,
    };
  },
  methods: {
    handle_virtualLogin() {
      let param = {
        token: this.param.token,
      };
      $loginAPI.getJXlogin(
        { token: this.param.token || window.JXtoken,
          loginName: this.param.loginName,
          userName: this.param.userName,
          userMobile: this.param.userMobile,
          companyId: this.param.companyId,
          timestamp: this.param.timestamp,
          sign: this.param.sign
          },
        (res) => {
          if (res.code == 0) {
            // 保存token
            // debugger
            setCookie("token", res.content.token);
            setSessionStorage("accountInfo", res.content.userInfo);
            window.sessionStorage.setItem("SysUserCode", res.content.username);
            window.sessionStorage.setItem("userName", res.content.userName);
            this.showAllLoading = false;
            this.$router.push({ path: "/budget/home" });
          } else {
            this.showAllLoading = false;
            this.$message.error(res.message);
          }
        },
        (err) => {
          this.showAllLoading = false;
        }
      );
    },
  },
  created() {
    this.param = getRequestParams();
    this.$nextTick(() => {
      this.handle_virtualLogin();
    });
  },
};
</script>

<style lang="scss" scoped>
.virtualLogin_container {
  width: 100%;
  height: 100%;
}
</style>